/**
 * @param {number} x
 * @return {number}
 */
var mySqrt = function (x) {
  let low = 0
  let high = x
  while (low <= high) {
      let mid = low + ((high - low) >> 1)
      if ((mid * mid) <= x) {
          if (((mid + 1) * (mid + 1)) > x) {
              return mid
          } else {
              low = mid + 1
          }
      } else {
          high = mid - 1
      }
  }
  return 0
};